﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExamStrategy.Question;

namespace ExamStrategy.Answer
{
    class Bob : IExamStrategy
    {
        public int GetMaxScore(int[] values, int[] times)
        {
            int[] res = new int[101];


            for (int i = 1; i < res.Length; i++)
            {
                res[i] = -1;
            }

            for (int i = 0; i < values.Length; i++)
            {
                for (int j = res.Length - 1; j >= 0; j--)
                {
                    if (res[j] >= 0 && j + times[i] < res.Length)
                    {
                        checked
                        {
                            res[j + times[i]] = Math.Max(res[j] + values[i], res[j + times[i]]);
                        }

                    }
                }
            }

            Array.Sort(res);
            Array.Reverse(res);
            return res[0];
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }
    }
}
